package com.chenyun.sys.controller;

import com.chenyun.bus.domain.Goods;
import com.chenyun.bus.service.impl.GoodsServiceImpl;
import com.chenyun.bus.vo.GoodsVo;
import com.chenyun.sys.domain.ChartGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/desk")
public class DeskGoodsController {

    @Autowired
    private GoodsServiceImpl goodsService;


    @GetMapping("/chart")
    public HashMap<String, List> chart(){
        ArrayList<ChartGoods> chartGoodsList = new ArrayList<>();
        HashMap<String, List> hashMap = new HashMap<>();
        List<Goods> list = goodsService.list();
        for (Goods goods : list) {
            chartGoodsList.add(new ChartGoods(goods.getGoodsname()+"--规格:"+goods.getSize(),goods.getNumber()));
        }
        hashMap.put("data",chartGoodsList);
        return hashMap;
    }


}
